package com.abredatos.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class EntityOpenHelper extends SQLiteOpenHelper {
	private static final String TAG = "EntityOpenHelper";
	private static final int DATABASE_VERSION = 2;
	private static final String DATABASE_NAME = "abredatos";
	private static final String ENTITY_TABLE_NAME = "entities";
	private static final String ENTITY_TABLE_CREATE =
	               "CREATE TABLE " + ENTITY_TABLE_NAME + " (id integer primary " +
	               		"key autoincrement, presupuesto float not null, url text not " +
	               		"null, proyecto text not null, categoria integer not null," +
	               		" coordx float not null, coordy float not null);";

	EntityOpenHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		
	}


	@Override
	public void onCreate(SQLiteDatabase db) {

		db.execSQL(ENTITY_TABLE_CREATE);
	}

	 @Override
     public void onUpgrade(SQLiteDatabase db, int oldVersion, 
     int newVersion) 
     {
         Log.w(TAG, "Upgrading database from version " + oldVersion 
                 + " to "
                 + newVersion + ", which will destroy all old data");
         db.execSQL("DROP TABLE IF EXISTS entities");
         onCreate(db);
     }
}
